<?php
	/**
	 * 品牌管理控制器
	 */
	class BrandAction extends CommonAction{

		//商品品牌管理视图
		public function index(){
			import('ORG.Util.Page');
			$db = M('brand');
			$brandCounts = $db->count();
			$page = new Page($brandCounts, 4);
			$limit = $page->firstRow . ',' . $page->listRows;
			$brands = $db->limit($limit)->select();
			$this->brandCounts = $brandCounts;
			$this->brands = $brands;
			$this->page = $page->show();
			$this->display();
		}

		//添加商品品牌视图
		public function addBrand(){
			$this->display();
		}

		//处理添加的商品品牌
		public function runAddBrand(){
			$data = array(
				'name' => $this->_post('typename'),
				'logo' => $this->_post('logo'),
				'hot' => $this->_post('hot')
				);
			$db = M('brand');
			if($db->data($data)->add()){
				$this->success('添加品牌数据成功！',U('index'));
			}else{
				$this->error('添加品牌数据失败，请重试！');
			}
		}
	}
?>